<doc>鼠标绘制工具</doc>
<template>
  <div class="draw-div">
    <button class="draw-btn" @click="draw()">1. 绘制</button>
    <button class="draw-btn" @click="edit()">2. 编辑</button>
    <button class="draw-btn" @click="finish()">3. 完成</button>
    <button class="draw-btn" @click="del()">4. 删除</button>
  </div>
</template>
<script>
export default {
  props: ["mapObject"],

  data() {
    return {};
  },

  methods: {
    // 开始绘制
    draw() {
      this.mapObject.drawPolygon("wjwDraw").then((points) => {
        this.$emit("drawFinsh", points);
      }); // 开始绘制多边形覆盖物
    },

    // 编辑
    edit() {
      this.mapObject.editDrawPolygon(); // 开始绘制多边形覆盖物
    },

    // 完成
    finish() {
      this.mapObject.finishDrawPolygon("wjwDraw").then((points) => {
        this.$emit("drawFinsh", points);
      });
    },

    // 删除
    del() {
      this.mapObject.removeInteractionForPolygon();
      this.mapObject.removeVectorLayer("wjwDraw");
    },
  },
};
</script>
<style scoped>
.draw-div {
  position: absolute;
  right: 20px;
  top: 10px;
  font-size: 12px;
  padding: 5px 10px;
  background-color: #fff;
  box-shadow: 0 2px 2px rgb(0 0 0 / 15%);
}

.draw-btn {
  width: 100%;
  margin: 5px 0;
  cursor: pointer;
}
</style>
